/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * Licensed under Simplified BSD License
 *
 *  
 *
 * @author: jin Chen
 * @date: Jan 28, 2005$
 * @version: 1.0
 */
package edu.psu.geovista.app.plot.ruler.tick;


import javax.swing.*;
import java.awt.*;

public class LineTick extends BasicTick{

    int length;//tick length
    
    public void paintComponent(Graphics g) {
         Point p=this.getLocation();

        Point ep = getTickEnd(p);

        g.drawLine(p.x, p.y,ep.x,ep.y);
    }
    //return end point of tick
    protected  Point getTickEnd(Point p) {
        Point ep=new Point();
        int ex=0,ey=0;//end point of tick

        switch (this.getOrient() ){
            case SwingConstants.TOP:
                ex=p.x;
                ey=p.y- this.getLength();
                break;
             case SwingConstants.BOTTOM:
                ex=p.x;
                ey=p.y+ this.getLength();
                break;
             case SwingConstants.LEFT:
                ex=p.x- this.getLength();
                ey=p.y;
                break;
             case SwingConstants.RIGHT :
                ex=p.x+ this.getLength();
                ey=p.y;
                break;
              default: assert false;//not expect happen;

        }
        ep.setLocation(ex,ey);
        return ep;
    }


    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }
}
